//
//  UIWebView+ActualHeight.m
//  mmbang
//
//  Created by CuiPanJun on 14-9-3.
//  Copyright (c) 2014年 iyaya. All rights reserved.
//

#import "UIWebView+ActualHeight.h"

@implementation UIWebView (ActualHeight)

- (void)autoFitHeight{
    CGRect frame = self.frame;
    frame.size.height = 1;
    self.frame = frame;
    CGSize fittingSize = [self sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    self.frame = frame;
}

- (CGFloat)actualHeight{
    CGRect originFrame = self.frame;
    CGRect frame = self.frame;
    frame.size.width = 320;
    frame.size.height = 1;
    self.frame = frame;
    CGSize fittingSize = [self sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    self.frame = originFrame;
    return fittingSize.height;
}

- (CGSize)windowInnerSize{
    CGSize size;
    size.width = [[self stringByEvaluatingJavaScriptFromString:@"window.innerWidth"] doubleValue];
    size.height = [[self stringByEvaluatingJavaScriptFromString:@"window.innerHeight"] doubleValue];
    return size;
}

@end
